package com.jews.securityleam.authentication.sms;

import lombok.Getter;
import lombok.Setter;
import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;

import java.util.Collection;

public class SmsToken extends AbstractAuthenticationToken {

    @Getter
    @Setter
    private SmsAuthRequest smsAuthRequest;

    public SmsToken(SmsAuthRequest smsAuthRequest, Collection<? extends GrantedAuthority> authorities) {
        super(authorities);
        this.smsAuthRequest = smsAuthRequest;
    }

    @Override
    public Object getCredentials() {
        return smsAuthRequest.getPhone();
    }

    @Override
    public Object getPrincipal() {
        return smsAuthRequest.getVerifyCode();
    }
}
